import 'package:flutter/material.dart';

import '../../routes.dart';
import '../../widgets/common_floating_action_bottom.dart';
import '../../widgets/room_list_item_widget.dart';
import '../home/tab_search/data_list.dart';

class ManagerRoom extends StatelessWidget {
  const ManagerRoom({super.key});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 2,
      initialIndex: 0,
      child: Scaffold(
        floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
        floatingActionButton: CommomFloatingActionBottom(
          titleText: '发布房源',
          onClick: () {
            Navigator.of(context).pushNamed(Routes.roomAdd);
          },
        ),
        appBar: AppBar(
          title: const Text('房屋管理'),
          bottom: const TabBar(
            tabs: [
              Padding(
                padding: EdgeInsets.all(9.0),
                child: Text(
                  '已租',
                  style: TextStyle(fontSize: 20),
                ),
              ),
              Padding(
                padding: EdgeInsets.all(9.0),
                child: Text('空置', style: TextStyle(fontSize: 20)),
              )
            ],
          ),
        ),
        body: TabBarView(
          children: [
            ListView(
              children: dataList
                  .map((e) => RoomListItemWidget(
                        data: e,
                      ))
                  .toList(),
            ),
            ListView(
              children: dataList
                  .map((e) => RoomListItemWidget(
                        data: e,
                      ))
                  .toList(),
            )
          ],
        ),
      ),
    );
  }
}
